<?php

/**
 * @author ducnhat
 * @email ddnhat@gmail.com
 * @copyright 2014
 */

class Default_Form_AccountLogin{
	
	protected $_isError = false;
	protected $_messageError = null;
    protected $_arrData = null;
    
    public function __construct($params = array()){
        $translate = Zend_Registry::get('Zend_Translate');
        
        $validatorUsername = new Zend_Validate();
        $validatorPassword = new Zend_Validate();
        
        $validatorUsername->addValidator(new Zend_Validate_NotEmpty(), true);
        
        $validatorPassword->addValidator(new Zend_Validate_NotEmpty(), true);
        
        
        if(!$validatorUsername->isValid($params['username'])){
            $this->_messageError['username'] = $translate->_('username') . current($validatorUsername->getMessages());
            $this->_arrData['username'] = '';
            $this->_isError = true;
        }else{
            $this->_arrData['username'] = $params['username'];
        }
        
        if(!$validatorPassword->isValid($params['password'])){
            $this->_messageError['password'] = $translate->_('password') . current($validatorPassword->getMessages());
            $this->_arrData['password'] = '';
            $this->_isError = true;
        }else{
            $this->_arrData['password'] = $params['password'];
        }
    }
    
    public function isError(){
    	return $this->_isError;
    }
    
    public function getMessageError(){
        return $this->_messageError;
    }
    
    public function getData(){
        return $this->_arrData;
    }
}